//
//  CartView.m
//  Ccsd_user
//
//  Created by hwd on 17/9/12.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "CartView.h"
#import "UILabel+HWDUILabel.h"
@implementation CartView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    [self setBackgroundColor:[UIColor whiteColor]];
    //购物车图片
    UIImageView *imgView = [UIImageView new];
    imgView.image = [UIImage imageNamed:@"Shop_cart"];
    [self addSubview:imgView];
    [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(15*screenW_6));
        make.top.equalTo(@(-10*screenW_6));
        make.size.mas_equalTo(CGSizeMake(50*screenW_6, 50*screenW_6));
    }];
    
    //订单提交图片
    self.commitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.commitBtn.backgroundColor = blueColor;
    [self.commitBtn setTitle:@"提交订单" forState:UIControlStateNormal];
    [self.commitBtn setTitleColor:[UIColor whiteColor]  forState:UIControlStateNormal];
    [self.commitBtn addTarget:self action:@selector(commitAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.commitBtn];
    [self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self).offset(0);
        make.right.bottom.top.equalTo(@0);
        make.height.equalTo(@(45*screenW_6));
        make.width.equalTo(@(110*screenW_6));
        make.top.equalTo(@0);
    }];
    
    //订单合计
    UILabel *oTotalConstLab = [UILabel new];
    oTotalConstLab.textColor = [UIColor blackColor];
    oTotalConstLab.font = [UIFont systemFontOfSize:17*screenW_6];
    oTotalConstLab.textAlignment = NSTextAlignmentLeft;
    oTotalConstLab.text = @"实付款:";
    [self addSubview:oTotalConstLab];
    [oTotalConstLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imgView.mas_right).offset(15*screenW_6);
        make.right.equalTo(self.commitBtn.mas_left).offset(-10*screenW_6);
        make.height.equalTo(@(45*screenW_6));
        make.top.equalTo(@0);
    }];
}

- (void)commitAction
{
    if (_block)
    {
        _block();
    }
}
@end
